/**
 * 
 */
package pms.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

/** 
 * Controller to generate the Home Page basics to be rendered by a view. 
 * It extends the convenience class AbstractController that encapsulates most 
 * of the drudgery involved in handling HTTP requests. 
/**
 * @author roman.zaglauer@googlemail.com
 *
 */
public class SaveKategorie extends AlleKategorien{
	protected ModelAndView handleRequestInternal(
			HttpServletRequest httpServletRequest,
			HttpServletResponse httpServletResponse) throws Exception {
		httpServletRequest.setCharacterEncoding("UTF-8");
		int id = Integer.parseInt(httpServletRequest.getParameter("id"));
		String kategoriebezeichnung = httpServletRequest.getParameter("kategoriebezeichnung");
		if (id == 0) {
			getKategorieDao().create(kategoriebezeichnung);
		} else {
			getKategorieDao().modify(id, kategoriebezeichnung);
		}
		return super.handleRequestInternal(httpServletRequest, httpServletResponse);
	}
}
